home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / iostats / iostats.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-05  |  2.2 KB  |  86 lines

  1. /* 
  2.  * iostats.c --
  3.  *
  4.  *    Measure disk usage.
  5.  *
  6.  * Copyright (C) 1986 Regents of the University of California
  7.  * All rights reserved.
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  */
  16.  
  17. #ifndef lint
  18. static char rcsid[] = "$Header: /sprite/src/cmds/iostats/RCS/iostats.c,v 1.1 90/10/05 12:54:03 mendel Exp Locker: mendel $ SPRITE (Berkeley)";
  19. #endif not lint
  20.  
  21. #include <sprite.h>
  22. #include <status.h>
  23. #include <option.h>
  24. #include <stdlib.h>
  25. #include <stdio.h>
  26. #include <sysStats.h>
  27.  
  28. /*
  29.  * Command line options.
  30.  */
  31.  
  32. int    numDisks = -1;
  33.  
  34. Option optionArray[] = {
  35.     {OPT_INT, "numDisks", (Address) &numDisks, 
  36.     "\tPrint out disk usage for this number of disks."},
  37. };
  38. int numOptions = sizeof(optionArray) / sizeof(Option);
  39.  
  40.  
  41. /*
  42.  *----------------------------------------------------------------------
  43.  *
  44.  * main --
  45.  *
  46.  *    Collects arguments and branches to the code for the command.
  47.  *
  48.  * Results:
  49.  *    None.
  50.  *
  51.  * Side effects:
  52.  *    Calls the command.
  53.  *
  54.  *----------------------------------------------------------------------
  55.  */
  56. main(argc, argv)
  57.     int argc;
  58.     char *argv[];
  59. {
  60.     ReturnStatus status = SUCCESS;    /* status of system calls */
  61.     Sys_DiskStats    *statsPtr;
  62.     char        *memPtr;
  63.  
  64.     argc = Opt_Parse(argc, argv, optionArray, numOptions);
  65.  
  66.     if (numDisks == -1) {    /* unset */
  67.     numDisks = 100;
  68.     }
  69.     memPtr =  malloc(numDisks * sizeof (Sys_DiskStats));
  70.     bzero(memPtr, numDisks * sizeof (Sys_DiskStats));
  71.  
  72.     status = Sys_Stats(SYS_DISK_STATS, numDisks, memPtr);
  73.     statsPtr = (Sys_DiskStats *) memPtr;
  74.  
  75.     while (statsPtr->name[0] != 0) {
  76.     printf("name: %s\n", statsPtr->name);
  77.     printf("controllerID: %d\n", statsPtr->controllerID);
  78.     printf("numSamples: %d\n", statsPtr->numSamples);
  79.     printf("idleCount: %d\n", statsPtr->idleCount);
  80.     printf("diskReads: %d\n", statsPtr->diskReads);
  81.     printf("diskWrites: %d\n", statsPtr->diskWrites);
  82.     statsPtr++;
  83.     }
  84.     exit(status);
  85. }
  86.